<?php

namespace App\Models;

use App\MongoModel as Model;
use Illuminate\Support\Facades\Auth;

/**
 * Class WxClient
 * @package App\Models
 * @property string project_id  项目ID
 * @property string user_id     用户ID
 * @property array[string] customers   客户ID
 */
class AcceptRecord extends Model
{

    // 转移
    const MV = 'mv';
    // 复制
    const CP = 'cp';
    
    /**
     * 客户是否已被认领
     * @param $customer_id
     * @param $project_id
     * @return bool
     */
    public static function isAccept($customer_id, $project_id)
    {
        if (is_null($customer_id) OR is_null($project_id)) return false;
        return self::where([
            'project_id' => $project_id,
            "customers" => $customer_id
        ])->count()>0;
    }

    /**
     * 某个用户是否被认领
     * @param $customer_id
     * @param $user_id
     * @return bool
     */
    public static function isAcceptByUser($customer_id, $user_id)
    {
        if (is_null($customer_id) OR is_null($user_id)) return false;
        return self::where([
            "user_id" => $user_id,
            "customers" => $customer_id
        ])->count()>0;
    }

}
